package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    @AutoFill(OperationType.INSERT)
    void insertDish(Dish dish);

    @Select("select COUNT(*) from dish where name = #{name}")
    Integer selectDishByName(String name);

    List<Dish> selectList(Dish dishquery);

    void deleteDishByIds(List<Long> ids);

    Integer selectCountByIdsAndStatus(List<Long> ids);

    @Select("select id, name, category_id, price, image, description, status, create_time, update_time, create_user, update_user" +
            " from dish where id = #{id}")
    Dish selectById(Long id);

    @AutoFill(OperationType.UPDATE)
    void updateDish(Dish dish);

    @Select("select id, name, category_id, price, image, description, status, create_time, update_time, create_user, update_user" +
            " from dish where category_id = #{categoryId} and status = 1")
    List<Dish> selectByCategoryId(Long categoryId);

    @Select("select count(*) from dish where status = 0 and id = #{dishId}")
    Integer selectDishDisableById(Long dishId);

    Integer selectDisEnableStatusCountByDishId(List<SetmealDish> setmealDishes);

    List<DishItemVO> selectDishItemById(Long id);
}
